package demo.using;

import com.alibaba.fastjson.JSON;

import java.awt.event.ActionEvent;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;

/**
 * @author : GuoFei
 * @date : 2019/1/3 11:58
 */
public class LmdText {

    public interface ActionListener {
        void actionPerformed(ActionEvent e);
    }

    public interface Test{
        String testRes (String param1,String param2);
    }

    public static void main(String[] args) {
//        Test test = (param1, param2) -> param1 + param2;
//        System.out.println(test.testRes("2","3"));
        System.out.println("--------");
//        mapTest();
        System.out.println("--------");
//        filterTest();
        System.out.println("--------");
        runLambada();
        System.out.println("--------");
    }

    public void oldRunable() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("The old runable now is using!");
            }
        }).start();
    }

    public void iterTest() {
        List<String> languages = Arrays.asList("java","scala","python");
        //before java8
        for(String each:languages) {
            System.out.println(each);
        }
        //after java8
        languages.forEach(x -> System.out.println(x));
        languages.forEach(System.out::println);

        languages.forEach(System.out::println);

        languages.forEach(System.out::println);
    }

    public static void mapTest() {
        List<Double> cost = Arrays.asList(10.0, 20.0,30.0);
        cost.stream().map(x -> x + x*0.05).forEach(x -> System.out.println(x));
        cost.forEach(System.out::println);
    }

    public static void filterTest() {
        List<Double> cost = Arrays.asList(10.0, 20.0,30.0,40.0);
        List<Double> filteredCost = cost.stream().filter(x -> x > 25.0).collect(Collectors.toList());
        filteredCost.forEach(System.out::println);

    }

    public static void runLambada(){

        List<String> names = Arrays.asList("Jeee", "dSSJ", "JJJ");

        List<Integer> ints = Arrays.asList(12, 23, 45, 66);

        String name = String.join("----", names);

        String name1 = names.stream().map(String::toUpperCase).collect(Collectors.joining(","));

        System.out.println(name1);

    }


}

